//
//  BBBlobEventController.h
//  BBTouch
//
//  Created by ben smith on 5/29/08.
//  This file is part of BBTouch.
//
//  BBTouch is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.

//  BBTouch is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.

//  You should have received a copy of the GNU Lesser General Public License
//  along with BBTouch.  If not, see <http://www.gnu.org/licenses/>.
// 
//  Copyright 2008 Ben Britten Smith ben@benbritten.com .
//

#import <Cocoa/Cocoa.h>

// takes the raw blobs and tracks them, producing events when something novel happens

@class BBBlobEvent;
@class BBPixelBlob;

@interface BBBlobEventController : NSObject {
	NSMutableArray * activeBlobEvents; // holds all the 'active' blobs
	NSMutableArray * newBlobEvents; // holds all the 'active' blobs

	int currentBlobEventNumber; // used to give each new blob a unique id
	id delegate; // TODO: make a nice delegate interface object spec
}

+ (BBBlobEventController*)sharedBlobEventController;
- (BBBlobEvent*)matchingEvent:(BBPixelBlob*)aBlob;
- (BOOL)event:(BBBlobEvent*)aBlobEvent doesMatch:(BBPixelBlob*)aBlob;
- (float)distanceBetweenEvent:(BBBlobEvent*)theEvent andBlob:(BBPixelBlob*)aBlob;
- (void)awakeFromNib;
- (void)clearInactiveEvents;
- (void)handleMatch:(BBBlobEvent*)theEvent withBlob:(BBPixelBlob*)aBlob;
- (void)handleNewBlob:(BBPixelBlob*)aBlob;
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context;
- (void)setBlobs:(NSArray*)newBlobs;
- (void)setDefaultDelegate;
- (void)setDelegate:(id)anObject;
- (void)tryBlobDown:(BBBlobEvent*)theBlobEvent;
- (void)tryBlobDragged:(BBBlobEvent*)theBlobEvent;
- (void)tryBlobMovementFinished;
- (void)tryBlobUp:(BBBlobEvent*)theBlobEvent;

// 16 methods



@end
